<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
   
    <script src="../../scripts/boot.js" type="text/javascript">
        function check(frm) {
            console.log("frm")
            console.log(typeof frm)
            //所有的标签（html、xml）在js世界都是一个个对象
            var fpemail = frm.acname.value;
      
            if (fpemail == "") {
                alert("邮箱不能为空")
                return false;
            }
            return true;
        }
    </script>
</head>
<!--<body style="background-image: url('sourse/log.jpg');background-size: 100%">-->
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            
            <form id="form1" role="form" action="javascript:void(0)"    style="position: absolute;left: 40%;top: 40%;">
            <h3 id="info" style="color:#000000">个人信息</h3>
            <table>
            <tr>
           		<td>
           			<label for="username">用戶姓名</label>
           		</td>
                <td>    
                	<input style="height: 25px;margin-left:10px;padding-left: 10px;" type="text" 
                		class="mini-textbox" id="username" name="username" placeholder="请输入顾客"/> 
                </td>
            </tr>   

            <tr>           
                <td> 
                	<label for="phone">用戶电话</label> </td>
                </td>   
                <td>
                	<input style="height: 25px;margin-left:10px;padding-left: 10px;" type="text" 
                		class="mini-textbox" id="phone" name="phone" placeholder="请输入电话"/>     
                </td>
            </tr>
            <tr>     
            	<td>      
            		<label for="email">用戶邮箱</label>
            	</td>
                <td>    
                	<input style="height: 25px;margin-left:10px;padding-left: 10px;" type="text" 
                		class="mini-textbox" id="email" name="email" placeholder="请输入邮箱"/>
                </td>
            </tr>
            </table>
            <div style="text-align: center; padding: 10px;">
				<a class="mini-button" onclick="edit()"
					style="width: 60px; margin-right: 20px;">修改</a>
				<!--<a class="mini-button" style="width: 60px;" href="http://localhost:8080/frame/frame1/index.html">取消</a>-->
			</div>
			
            </form>
        </div>
    </div>
</div>
</body>
</html>

<script>
	//class="mini-textbox" 和 setData配合使用
    var httpreq=null;
    var ts = document.getElementById("ts")

    function edit() {
    var form = new mini.Form("form1");// new  FormData()

    //正常做法
    /* var username=$("#username").val()//jquery
    var phone=document.getElementById("phone").value//原生的做法
    var fpemail=$("#fpemail").val()//jquery */
        var o = form.getData();

    // //miniUi做法
    var username=mini.get("username").getValue()
    // var phone=mini.get("phone").getValue()
    var email=mini.get("email").getValue()
        if(username==""||email=="") {
            ts.innerHTML="用户名或密码不能为空"
            return
        }


          $.ajax({
              url:"../../customer/update",
              type:'post',
              contentType: 'application/json',//新

              data: JSON.stringify(o),
              success: function (text) {
                  console.log(text)
                  if (text.indexOf("OK")>-1) {
                      alert("OK")
                  } else {
                      alert("FAIL")
                  }

              },
              error: function () {
              }
          })

	}
    function message() {
        var form = new mini.Form("form1");// new  FormData()

            $.ajax({
                url: "../../customer/getinfo",
                // data:{method:"getinfo"},
                success: function (text) {
                    console.log(text)
                    //显示数据操作
                    // cname=text.subString(0)
                    /*   text jsString
               setData 是json */
                    //text=JSON.parse(text)
                    form.setData(text);
                    // message()
                },
                error: function () {
                }
            })
            }
    
 	// 页面加载完成后调用 getInfo 函数  
    $(document).ready(function() {  
       message()
   	});
	
</script>